﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;
using ProntuarioEletronico;
using ProntuarioEletronico.Repositorio;
using System.Data;


namespace ProntuarioEletronico.Banco
{
    public class BancoCadLogin
    {
        ConexaoMysql conect = new ConexaoMysql();

        public DataTable selectLogin(string login)
        {
            try
            {
                String sql = "SELECT senha FROM cadastro_medico WHERE login = '"+login+"'";
                conect.conn = new MySqlConnection(conect.conexaoMySQL);
                MySqlCommand cmd = new MySqlCommand(sql, conect.conn);
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                //da.SelectCommand = cmd;
                DataTable dt = new DataTable();
                da.Fill(dt);
                return dt;
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                conect.conn.Close();
            }
        }


        public void insertLogin(LoginMedico login)
        {
            try
            {
                string sql = "INSERT INTO ";
                conect.conn = new MySqlConnection(conect.conexaoMySQL);
                MySqlCommand cmd = new MySqlCommand(sql, conect.conn);
                cmd.Parameters.AddWithValue("camponobanco", login.UsuarioMedico);
                cmd.Parameters.AddWithValue("camponobanco", login.SenhaMedico);
               conect.conn.Open();
                cmd.ExecuteNonQuery();

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                conect.conn.Close();
            }
        }

        public void updateLogin(LoginMedico login)
        {
            try
            {

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {

            }

        }

        public void deleteLogin(LoginMedico login)
        {
            try
            {

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {

            }
        }
    }
}